package com.atwisdom.star.serviceController.equipmentMaintain;

import com.alibaba.fastjson.JSONObject;
import com.atwisdom.star.common.vo.ResultInfo;
import com.atwisdom.star.exception.pojo.BusinessException;
import com.atwisdom.star.log.aop.StarAnnotation;
import com.atwisdom.star.service.equipment.CheckInspectionService;
import com.atwisdom.star.service.equipment.MaintainInspectionService;
import com.atwisdom.star.service.equipment.SpotInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: InspectionServiceController
 * @ Description:
 * @author:王红艳
 * @date:
 */
@RestController
@RequestMapping("/inspection")
public class InspectionServiceController {
    @Autowired
    private CheckInspectionService checkInspectionService;

    @Autowired
    private SpotInspectionService spotInspectionService;

    @Autowired
    private MaintainInspectionService maintainInspectionService;


    /**
     * 根据设备id查询巡检设备数据
     * @param data
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/queryEquipmentCheckTemByEquId")
    public ResultInfo<?> queryEquipmentCheckTemByEquId(@RequestBody JSONObject data)  throws BusinessException {
        return checkInspectionService.queryEquipmentTemByEquId(data);
    }
    /**
     * 根据计划模版id,className,type生成执行计划数据
     * @param data
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/executeCheckPlan")
    public ResultInfo<?> executeCheckPlan(@RequestBody JSONObject data)  throws BusinessException {
        return checkInspectionService.executePlan(data);
    }

    /**
     * 审批计划
     * @param data 包含计划审批信息的pointer实例数据及approveValues审批数据。
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/approveCheckPlan")
    public ResultInfo<?> approveCheckPlan(@RequestBody JSONObject data)  throws BusinessException {
        return checkInspectionService.approvePlan(data);
    }

    /**
     * 加入知识库
     * @param data 知识库数据
     * @return 报工数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/addCheckKnowledge")
    public ResultInfo<?> addCheckKnowledge(@RequestBody JSONObject data)  throws BusinessException {
        return checkInspectionService.addKnowledge(data);
    }

    /**
     * 报工
     * @param data 报工参数
     * @return 报工数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/workCheckReport")
    public ResultInfo<?> workCheckReport(@RequestBody JSONObject data)  throws BusinessException {
        return checkInspectionService.workReport(data);
    }
    /**
     * 根据设备id查询巡检设备数据
     * @param data
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/queryEquipmentSpotTemByEquId")
    public ResultInfo<?> queryEquipmentSpotTemByEquId(@RequestBody JSONObject data)  throws BusinessException {
        return spotInspectionService.queryEquipmentTemByEquId(data);
    }
    /**
     * 根据计划模版id,className,type生成执行计划数据
     * @param data
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/executeSpotPlan")
    public ResultInfo<?> executeSpotPlan(@RequestBody JSONObject data)  throws BusinessException {
        return spotInspectionService.executePlan(data);
    }

    /**
     * 加入知识库
     * @param data 知识库数据
     * @return 报工数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/addSpotKnowledge")
    public ResultInfo<?> addSpotKnowledge(@RequestBody JSONObject data)  throws BusinessException {
        return spotInspectionService.addKnowledge(data);
    }

    /**
     * 报工
     * @param data 报工参数
     * @return 报工数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/workSpotReport")
    public ResultInfo<?> workSpotReport(@RequestBody JSONObject data)  throws BusinessException {
        return spotInspectionService.workReport(data);
    }

    /**
     * 审批计划
     * @param data 包含计划审批信息的pointer实例数据及approveValues审批数据。
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/approveSpotPlan")
    public ResultInfo<?> approveSpotPlan(@RequestBody JSONObject data)  throws BusinessException {
        return spotInspectionService.approvePlan(data);
    }

    /**
     * 根据设备id查询巡检设备数据
     * @param data
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/queryEquipmentMaintainTemByEquId")
    public ResultInfo<?> queryEquipmentMaintainTemByEquId(@RequestBody JSONObject data)  throws BusinessException {
        return maintainInspectionService.queryEquipmentTemByEquId(data);
    }
    /**
     * 根据计划模版id,className,type生成执行计划数据
     * @param data
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/executeMaintainPlan")
    public ResultInfo<?> executeMaintainPlan(@RequestBody JSONObject data)  throws BusinessException {
        return maintainInspectionService.executePlan(data);
    }

    /**
     * 加入知识库
     * @param data 知识库数据
     * @return 报工数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/addMaintainKnowledge")
    public ResultInfo<?> addMaintainKnowledge(@RequestBody JSONObject data)  throws BusinessException {
        return maintainInspectionService.addKnowledge(data);
    }

    /**
     * 报工
     * @param data 报工参数
     * @return 报工数据
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/workMaintainReport")
    public ResultInfo<?> workMaintainReport(@RequestBody JSONObject data)  throws BusinessException {
        return maintainInspectionService.workReport(data);
    }

    /**
     * 审批计划
     * @param data 包含计划审批信息的pointer实例数据及approveValues审批数据。
     * @return
     * @throws BusinessException
     */
    @StarAnnotation
    @PostMapping("/approveMaintainPlan")
    public ResultInfo<?> approveMaintainPlan(@RequestBody JSONObject data)  throws BusinessException {
        return maintainInspectionService.approvePlan(data);
    }
}
